package com.cheetah.start.module.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cheetah.start.common.enums.FileStatusEnum;
import com.cheetah.start.module.system.domain.SysFile;
import com.cheetah.start.module.system.mapper.SysFileMapper;
import com.cheetah.start.module.system.service.ISysFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author xjh
 * @create 2021/7/4
 **/
@Slf4j
@Service
public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> implements ISysFileService {
    @Autowired
    private SysFileMapper sysFileMapper;


    @Override
    public void setNotUse(String filePath) {
        QueryWrapper<SysFile> wrapper = new QueryWrapper<>();
        wrapper.eq("file_path", filePath);
        SysFile one = sysFileMapper.selectOne(wrapper);
        if (one == null) {
            return;
        }
        one.setFileStatus(FileStatusEnum.NOT_USE.getCode());
        int i = sysFileMapper.updateById(one);
        log.info("文件更新结果:[{}]", i);
    }
}
